<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>博客管理</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
  <link rel="stylesheet" th:href="@{/stage/css/me.css}" >
  <link rel="stylesheet" th:href="@{/stage/css/iconfont.css}"/>
  <link rel="icon" type="image/x-icon" th:href="@{${webconfig.websiteicon}}" />
</head>
<body>

  <!--导航-->
  <footer th:replace="backstatic/head::footer-fragment-head"></footer>
  <div class="ui attached pointing menu">
    <div class="ui container">
      <div class="right menu">
        <a href="#" th:href="@{'/admin/bloginput'}" class=" item">发布</a>
        <a href="#" th:href="@{'/admin/adblog'}" class="teal active item">列表</a>
      </div>
    </div>
  </div>

  <!--中间内容-->
  <div  class="m-container-small m-padded-tb-big">
    <div class="ui container">
      <div  class="ui secondary segment form">
        <form th:action="@{'/admin/adsearch'}" method="get">
          <input type="hidden" name="page" >
          <div class="inline fields">
            <div class="field">
              <input type="text" name="title" placeholder="标题">
            </div>
            <div class="field">
              <div class="ui labeled action input">
                <div class="ui type selection dropdown">
                  <input type="hidden" name="typeId">
                  <i class="dropdown icon"></i>
                  <div class="default text">分类</div>
                  <div class="menu">
                    <div  class="item" th:each="alp:${alltp}" data-value="1" th:data-value="${alp.articletypeid}" th:text="${alp.artypename}" >错误日志</div>
                  </div>
                </div>
                <button id="clear-btn" class="ui compact button">clear</button>
              </div>

            </div>
            <div class="field">
              <button  type="submit" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
            </div>
          </div>
        </form>
      </div>
      <div id="table-container">
        <table  class="ui compact teal table">
          <thead>
          <tr>
            <th>ID</th>
            <th>标题</th>
            <th>类型</th>
            <th>观看量</th>
            <th>状态</th>
            <th>更新时间</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr th:each="bal:${pali.list}">
            <td th:text="${bal.id}">1</td>
            <td th:text="${bal.articletitle}">刻意练习清单</td>
            <td th:text="${bal.artype.artypename}">认知升级</td>
            <td th:text="${bal.watchnumber}">1212182</td>
            <td th:text="${bal.state==0?'草稿':'发布'}">1212182</td>
            <td th:text="${#dates.format(bal.createtime,'yyyy-MM-dd HH:mm:ss')}">2017-10-02 09:45</td>
            <td>
              <a th:href="@{'/admin/blogin/'+${bal.id}}"  class="ui mini teal basic button">编辑</a>
              <a th:href="@{'/admin/delblog/'+${bal.id}}"  class="ui mini red basic button">删除</a>
            </td>
          </tr>
          </tbody>
          <tfoot>
          <tr>
            <th colspan="7">
              <th:block th:if="${statue==400}">
                <div class="ui mini pagination menu"  >
                  <a th:href="@{'/admin/adsearch?typeId='+${tyid}+'&title='+${tit}+'&pagenum='+${pali.prePage}}" class="item" >上一页</a>
                  <a th:href="@{'/admin/adsearch?typeId='+${tyid}+'&title='+${tit}+'&pagenum='+${pali.nextPage}}" class=" item">下一页</a>
                </div>
              </th:block>
              <th:block th:if="${statue!=400}">
                <div class="ui mini pagination menu"  >
                  <a th:href="@{'/admin/adblog?pagenum='+${pali.prePage}}" class="item" >上一页</a>
                  <a th:href="@{'/admin/adblog?pagenum='+${pali.nextPage}}" class=" item">下一页</a>
                </div>
              </th:block>
              <a href="#" th:href="@{'/admin/bloginput'}" class="ui mini right floated teal basic button">新增</a>
            </th>
          </tr>
          </tfoot>
        </table>

        <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
          <i class="close icon"></i>
          <div class="header">提示：</div>
          <p th:text="${message}">恭喜，操作成功！</p>
        </div>

      </div>

    </div>
  </div>

  <br>
  <br>
   <footer  th:replace="backstatic/foot::footer-fragment"></footer>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
  <script>
    $('.menu.toggle').click(function () {
      $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
      on : 'hover'
    });

    //消息提示关闭初始化
    $('.message .close')
      .on('click', function () {
        $(this)
          .closest('.message')
          .transition('fade');
      });

    $('#clear-btn')
      .on('click', function() {
        $('.ui.type.dropdown')
          .dropdown('clear')
        ;
      })
    ;

    function page(obj) {
      $("[name='page']").val($(obj).data("page"));
      loaddata();
    }

    $("#search-btn").click(function () {
      $("[name='page']").val(0);
      loaddata();
    });
    function loaddata() {
      $("#table-container").load(/*[[@{/admin/blogs/search}]]*/"/admin/blogs/search",{
        title : $("[name='title']").val(),
        typeId : $("[name='typeId']").val(),
        recommend : $("[name='recommend']").prop('checked'),
        page : $("[name='page']").val()
      });
    }

    $(function() {
      $("#alla a").eq(0).attr("class","active m-item item m-mobile-hide");
    })

  </script>
</body>
</html>